package com.example.myapplication.model;

/**
 * 温度数据模型
 * 对应云平台返回的单个温度数据点
 */
public class TemperatureData {
    private long ts;        // 时间戳
    private String value;   // 温度值

    public TemperatureData() {
    }

    public TemperatureData(long ts, String value) {
        this.ts = ts;
        this.value = value;
    }

    public long getTs() {
        return ts;
    }

    public void setTs(long ts) {
        this.ts = ts;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    /**
     * 获取温度值的数字形式
     * @return 温度值（摄氏度）
     */
    public double getTemperatureValue() {
        try {
            return Double.parseDouble(value);
        } catch (NumberFormatException e) {
            return 0.0;
        }
    }

    @Override
    public String toString() {
        return "TemperatureData{" +
                "ts=" + ts +
                ", value='" + value + '\'' +
                '}';
    }
}
